package at.ac.lbg.media.vis.client.theme.view
{
	import flare.vis.data.NodeSprite;
	
	import mx.collections.ArrayCollection;
	
	public class Artwork extends NodeSprite {
		
		public var id:Number;
		public var title:String;
		public var year:int;
		public var nica:Boolean;
		public var origX:Number;
		public var origY:Number;
		
		public var origHeight:Number;
		public var origWidth:Number;
		
		public var coords:String;
		public var stackCount:int;
		// will be set only for the top artwork of each stack
		public var stack:ArtworkStack;
		public var categoryIds:ArrayCollection = new ArrayCollection();
		// true is cat of this artwork in legend is selected
		private var _highlightMe:Number = -1;
		
		public function Artwork(obj:Object) { 
			super();
			id = obj.id;
			title = obj.title;
			year = obj.year;
			nica = obj.nica != 0;
			if (title.length > 25) {
				title = title.substr(0, 20).concat("...");
			}
			if (nica) {
				title += "\n(Golden Nica " + year + ")";
			}
			origX = obj.x;
			origY = obj.y;
			coords = origX + " " + origY;
			stackCount = obj.stackCount;
			var cats:ArrayCollection = obj.categories;
			for (var i:int = 0; i < cats.length; i++) {
				categoryIds.addItem(cats[i].id);
			}

		}
		
		public function set highlightMe(n:Number):void {
			if (n != this._highlightMe) {
				this._highlightMe = n;
				dirty();
			}
		}
		
		
		public function get highlightMe():Number {
			return _highlightMe;
		}
		
	}
}